#include <stdio.h>
#define CODE 0
#define LINE_COMMENT 1
#define BLOCK_COMMENT 2
char buff1[1048576];
int len1;
char buff2[1048576];
int len2;

void load_file(const char *filename, char *buff, int *pbufflen)
{
  FILE *fp = fopen(filename, "r");
  *pbufflen = fread(buff, 1, 1048576, fp);
  fclose(fp);
}

void remove_comment(const char *in, int inlen, char *out, int *poutlen)
{
  int state = CODE;
  while (inlen)
  {
    //printf("%d\n",state);
    switch (state)
    {
    case CODE:
      if (inlen >= 2 && in[0] == '/' && in[1] == '/') {
        state = LINE_COMMENT;
        in += 2;
        inlen -= 2;
      } else if (inlen >= 2 && in[0] == '/' && in[1] == '*') {
        state = BLOCK_COMMENT;
        in += 2;
        inlen -= 2;
      } else {
        *out = in[0];
	      out++;
        in += 1;
        inlen -= 1;
	      (*poutlen)++;
      }
      break;
    case LINE_COMMENT:
      if (in[0] == '\n') {
	      state = CODE;
	      in++;
	      inlen--;
      } else {
	      in++;
	      inlen--;
      }
      break;
    case BLOCK_COMMENT:
      if (inlen >= 2 && in[0] == '*' && in[1] == '/') {
	      state = CODE;
	      in += 2;
	      inlen -= 2;
      } else {
	      in++;
	      inlen--;
      }
      break;
    }
  }
}
int main(int argc, char **argv)
{
  load_file(argv[1], buff1, &len1);
  remove_comment(buff1, len1, buff2, &len2);
  puts(buff2);
  return 0;
}
